/**
 * @author songxz
 * @date 2022/11/11
 */

public class VolatoleDemo {
    public volatile static int inc=0;

    public void increase() {
        synchronized (this){

        }
        inc++;
    }

    public static void main(String[] args) throws InterruptedException {

        VolatoleDemo volatoleDemo = new VolatoleDemo();
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5000; j++) {
                new Thread(()->{
                    volatoleDemo.increase();
                }).start();
            }
        }
        

        // 等待1.5秒，保证上面程序执行完成
        Thread.sleep(1500);

        System.out.println(inc);
    }
}
